<%@ page import="com.jkt.rms.commons.includes.*"%>
<%@ page import="com.jkt.rms.constants.IConstants"%>

<%@ page import="java.util.*"%>
<%@ page import="com.jkt.rms.business.*"%>
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="/spring"%>
<html>
<head>
<title><fmt:message key="lbl.title.createuser" /></title>
</head>
 <body><center>
 	<br>
	<div id="headerbar"><fmt:message key="lbl.title.createuser" /></div>
 	<div id="content">
	<div> 
		<c:if test="${ not empty errors.allErrors}">
		<div id="errorFieldSet" >
			<fieldset> 
 				<legend >Errors</legend> 				
 				  <c:forEach var="err" items="${errors.allErrors}">
					<spring:message code="${err.code}" arguments="${err.arguments[0]}" />
					<br />
				</c:forEach>
 			</fieldset>
		</div>
	</c:if> 
	
	<c:if test="${ not empty user.message}">
		<div id="infoFieldSet">
		<fieldset> 
		<legend >Messages</legend> 				
		<spring:message code="${user.message}"/>
		<br />
		</fieldset>
		</div>
	</c:if> 
  
	<table  width="90%" cellpadding="0" cellspacing="0" border = "0">
		
		<form:form method="POST" commandName="user" name="searchForm" title = "Search User">
			 
			
			
			 <tr valign="top" align="center">
			  	<td width="80%">
			  
			  
					  <fieldset>
					  	<legend ><strong>Search User </strong></legend>
					    <table border = "0" width = "80%" >
					    <tr>
					    	<td width = "25%" align="right">First Name:</td><td width = "25%" align="right"><form:input path ="srchFirstName"  tabindex="10" maxlength="50"/></td>
					    	<td width = "25%" align="right">Last Name:</td><td width = "25%" align="right"><form:input path ="srchLastName"  tabindex="20" maxlength="50"/></td>
					    </tr>
					    <tr>
					    	<td width = "25%" align="right">User Name:</td><td width = "25%" align="right"><form:input path  ="srchUserName"  tabindex="30" maxlength="50"/></td>
					    	<td width = "25%" align="right" >Role Name:</td><td width = "25%" align="right"><form:input path ="srchRoleName"  tabindex="40" maxlength="50"/></td>
					    </tr>
					    <tr>
					    	<td colspan="4">
			              		&nbsp;
			            	</td>
					    </tr>
					    <tr>
					    	<td colspan="4" align="right">
			              		<input class="value" type='button' value='Search'   tabindex="50" onclick="dosubmit('user','adduser.htm?method=search')">
			            		<input class="value" type='button' value='FindAll'   tabindex="60" onclick="dosubmit('user','adduser.htm?method=searchAll')">
			            	</td>
					    </tr>
					    </table>
					   </fieldset>
					
					   
				</td>
			</tr>
			
<tr>
<c:set value="<%=IConstants.ROLE_NAME %>" var="rolename"></c:set>
	<c:if test="${ not empty userSearch}">
	
	<td width="80%">
		<div id="SRCHR">
	<fieldset><legend>Users</legend>
	<table border = "1" align = "center" > 
	<tr bgcolor="#AAAAAA">
		<td>SNo</td><td>First Name</td><td>Last name</td><td>Email</td><td>User Name</td><td>Role Name</td><td>Active</td><td>Edit</td><td>&nbsp;</td>
	</tr>
	<c:forEach var="vo"	items="${userSearch}" varStatus="usrRowIndex" step="1">
		<tr>
		<td>${(usrRowIndex.index)+1}</td><td>${vo.firstName}&nbsp;</td><td>${vo.lastName}&nbsp;</td><td>${vo.email} </td><td>${vo.username} </td>
		
		<c:forEach var="roles"	items="${vo.listUserRoles}">
			<c:if test="${roles.authority != rolename}">
			<td>${roles.authority}&nbsp;</td>
			</c:if>
		</c:forEach>		
		<td>${vo.enabled}&nbsp;</td>
		<td> <a href="adduser.htm?method=editUI&username=${vo.username}&srchFirstName=<c:out value="${user.srchFirstName}"/>
		&srchLastName=<c:out value="${user.srchLastName}"/>&searchMethod=<c:out value="${user.searchMethod}"/>" > Edit </a>  </td>
		</tr>
		
	</c:forEach>
	</table>
	</fieldset>
	</div>
	</td>
</c:if> 
			</tr>
			</form:form>
			
			
			 <tr valign="top" align="center">
				<td width="80%">
			<div id = "ADDUSER">
				<form:form method="POST" commandName="user" action="adduser.htm?method=addUser" name="addUserForm" title = "Add User">
				  <fieldset>
				  <legend ><strong>Add User </strong></legend>
					<table width = "80%" border = "0" cellpadding="0" cellspacing="0" >
						
					  	<tr>
			            	<td align='right' class=header  width = "25%" >First Name:</td>
				            <td align='left' class=value width = "25%"> 
				           		<form:input   path="firstName" tabindex="1" maxlength="50"  />
			            	</td>
			            	
			            	<td align='right' class=header width = "25%" >Last Name:</td>
				            <td width = "25%">
				            <form:input   path="lastName" tabindex="2" maxlength="50" />
			            	</td>
			            	  	
			         	 </tr>
			          <tr>
			          	<td align='right' width = "25%">User Name:</td> 
			            		<td align='left' width = "15%">
			            			<form:input   path="username"  tabindex="3"  maxlength="50" />
			            </td>
			            <td align='right'  width = "25%" >Password:</td>
			            <td align='left' width = "25%">
			            <form:password path="password"  tabindex="4"  maxlength="50" />
			            </td>
			             </tr>
			             <tr>
			            
			            <td align='right'  width = "25%">E-Mail:</td>
			            <td align='left'  width = "25%">
			           	 <form:input   path="email"  tabindex="5"  maxlength="100"/>		
			            </td>
			            <td align='right'  width = "25%" >Role Name:</td>
			            	<td align='left'  width = "25%" >
			           		<form:select
								path="roleName" tabindex="6" cssStyle="width:160Px">
								<form:option value="0" label="Select" />
								<form:options items="${user.listRole}" itemValue="roleName" itemLabel="roleName"/>
						</form:select></td>	
			            
			          </tr>
			         
			          <tr>
			            <td colspan=4 align=center>
			          		&nbsp;
			            </td>
			          </tr>
			          <tr >
			            <td colspan="4" align="center">
			              <input class="value" type='submit' name='button' value='Save'   title="" tabindex="7">
			            </td>
			          </tr>
			     </table>
			     </fieldset>
			     </form:form>
			     </div>
      		</td>
		</tr>
	</table>	
		
		</div>
		<p>

		</p>
		<br>			
	</div>
<%@ include file="footer.jsp" %>
</center></body>
</html>
